package main

import (
	"context"
	"fmt"
	"net"
	"newtomicroc/grpcconn/pb"
	"google.golang.org/grpc"
)
type Children struct {

}

func (this *Children) SayHello(ctx context.Context,p *pb.Person) (*pb.Person,error) {
     p.Name="hello" +p.Name
     return p,nil
}
func main()  {
       //1 初始化 grpc 对象
	grpcServer:=grpc.NewServer()

	//注册服务

	pb.RegisterHelloServer(grpcServer,new(Children))

	//3设置监听 指定ip/port
	listener,err:=net.Listen("tcp","127.0.0.1:8800")
     if err!=nil
	{
		fmt.Println("listener err：",err)
		return
	}
	defer listener.Close()
    //4启动服务
    grpcServer.Serve(listener)




}
